// UserDefinedDisplayManager.h: interface for the UserDefinedDisplayManager class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_USERDEFINEDDISPLAYMANAGER_H__71E320BB_E7D0_41B6_BF1B_A016D0EA2EAC__INCLUDED_)
#define AFX_USERDEFINEDDISPLAYMANAGER_H__71E320BB_E7D0_41B6_BF1B_A016D0EA2EAC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "BaseMethodCallback.h"

struct UserDefinedDisplayItem;
class UserDefinedDisplay;

class UserDefinedDisplayManager : public BaseMethodCallback  
{
public:
	UserDefinedDisplayManager(CWnd * pOwner);
	virtual ~UserDefinedDisplayManager();

  virtual void Callback(BaseMethodPerformer * pPerformer);

  CWnd * GetpOwner() const {return m_pOwner;}
  void AddUserDefinedDisplay(const CString& strDisplayName, BYTE nShareFlag);
  void DeleteUserDefinedDisplay(const CString& strDisplayName);
  void RenameUserDefinedDisplay(const CString& strOldDisplayName, const CString& strNewDisplayName);
  void RefreshUserDefinedDisplay();
  void UserDefinedDisplayReady(DWORD dwMethodType, int nMethodAck);
  void UserDefinedDisplayContentReady(DWORD dwMethodType, int nMethodAck);
  void UserDefinedDisplayFailure();
  void EnableContextMenu(bool bEnable = true) {m_bEnableContextMenu = bEnable;}
  bool IsContextMenuEnabled() const {return m_bEnableContextMenu;}
  void QueryUserDefinedDisplayContent(UserDefinedDisplay * pUserDefinedDisplay);
  void SetUserDefinedDisplayContent(UserDefinedDisplay * pUserDefinedDisplay);
  UserDefinedDisplay * GetUserDefinedDisplayByName(const CString& strUserId, const CString& strDisplayName);

  HTREEITEM InsertUserDefinedDisplayToTreeCtrl(CTreeCtrl& treectrl, HTREEITEM hItemParent) const;

protected:
  void AddUserDefinedDisplay(UserDefinedDisplay * pUserDefinedDisplay);
  void DeleteUserDefinedDisplay(UserDefinedDisplay * pUserDefinedDisplay);
  void DeleteAllUserDefinedDisplay();
  UserDefinedDisplay * NewUserDefinedDisplay(UserDefinedDisplayItem * pUserDefinedDisplayItem);

  void DeleteUserDefinedDisplayItem();
  void DeleteUserDefinedDisplayItems();
  void GUIUpdateUserDefinedDisplay();
  void GUIUpdateUserDefinedDisplayContent();

protected:
  CWnd * m_pOwner;
  CMutex m_mutexUserDefinedDisplayItem;
  CMutex m_mutexUserDefinedDisplayItems;
  UserDefinedDisplayItem * m_pUserDefinedDisplayItem;
  std::vector<UserDefinedDisplayItem *> m_vecUserDefinedDisplayItems;
  std::vector<UserDefinedDisplay *> m_vecUserDefinedDisplay;
  BaseMethodPerformer * m_pPerformer;
  bool m_bEnableContextMenu;
  UserDefinedDisplay * m_pUserDefinedDisplay;
};

#endif // !defined(AFX_USERDEFINEDDISPLAYMANAGER_H__71E320BB_E7D0_41B6_BF1B_A016D0EA2EAC__INCLUDED_)
